/*
 * @Descripttion: 
 * @version: 
 * @Author: hzj-1510017964@qq.com
 * @Date: 2020-04-21 15:25:32
 * @LastEditors: hzj-1510017964@qq.com
 * @LastEditTime: 2020-05-07 10:12:00
 */



/**
 * 安装中间件
 */

const Sequelize = require('sequelize');  //安装sequelize

/**
 * 连接数据库
 */

const sqlConfig = {
    host: "106.13.160.144",   // 主机||IP
    user: "bookkeeping",       //用户名
    password: "2ebWmLW37fzLnawj",  //密码
    database: "bookkeeping"  //数据库
}

//连接数据库
const sequelize = new Sequelize(sqlConfig.database, sqlConfig.user, sqlConfig.password, {
    host: sqlConfig.host,
    dialect: 'mysql',  //数据库类型 mysql
    timezone: '+08:00',  //东八区时间
    pool: {
        max: 5,
        min: 0,
        acquire: 30000,
        idle: 10000
    },
    define: {
        timestamps: false,
        freezeTableName: true,
    }
});
//数据库监听
sequelize.authenticate()
    .then(() => {
        console.log('数据库连接成功...');
    })
    .catch(err => {
        console.error('数据库连接失败', err);
    });






module.exports = sequelize